const express = require("express");
const path = require("path");
const { registerPdfRoutes } = require("./pdf"); // 引入PDF模块

// 创建Express应用
const app = express();
const PORT = process.env.PORT || 3000;

// 中间件设置
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, "public")));

// 注册PDF相关路由
registerPdfRoutes(app);

// 路由
app.get("/", (req, res) => {
  res.send("欢迎使用Node.js服务器！");
});

app.get("/api/hello", (req, res) => {
  res.json({ message: "你好，世界！" });
});

// 启动服务器
app.listen(PORT, () => {
  console.log(`服务器运行在 http://localhost:${PORT}`);
});
